// @import
import HeroCtrl from "./HeroCtrl";
import MyCoroutine from "../comm/base/MyCoroutine";

/**
 * 执行死亡
 * 
 * @param SELF this 指针
 */
export function __doDie(SELF: HeroCtrl): void {
    if (null == SELF) {
        return;
    }

    // 停止协程
    MyCoroutine.stopCoroutine(SELF._strMoveTo_XCID);

    // 获取 Spine 骨骼控件
    let oSpSkeleton = SELF.node.getComponentInChildren(sp.Skeleton);
    oSpSkeleton.setAnimation(0, "Die", false);

    cc.find("Holder_SoundGroup/AudioSource_Die", SELF.node)
        .getComponent(cc.AudioSource)
        .play();

    cc.find("Holder_NameAndHP/Sprite_HP_0", SELF.node).active = false;
    cc.find("Holder_NameAndHP/Sprite_HP_1", SELF.node).active = false;

    let funTw = cc.tween;

    funTw(cc.find("Holder_NameAndHP", SELF.node))
        .delay(0.2)
        .to(0.64, { y: -24, }, { easing: "elasticOut", })
        .start();
}
